
* Open data
use "PaxPopuli_Global.dta", replace




**********
** Table 1
**********


* Model 1
xtreg violsd_onset csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.py##c.py##c.py, cl(countries_gwid) fe i(gwgroupid) 
estimates store m1
* Model 2
xtreg violsd_term csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.wy##c.wy##c.wy, cl(countries_gwid) fe i(gwgroupid) 
estimates store m2





***********
** Figure 2
***********


gen model = 1 in 1/2
replace model = 2 in 3/4
gen variable = .
replace variable = 1 in 1
replace variable = 1 in 3
replace variable = 2 in 2
replace variable = 2 in 4
gen pe = .
gen se = .

estimates restore m1
replace pe = _b[csdref2] if model == 1 & variable == 1
replace se = _se[csdref2] if model == 1 & variable == 1
replace pe = _b[usdref2] if model == 1 & variable == 2
replace se = _se[usdref2] if model == 1 & variable == 2
estimates restore m2
replace pe = _b[csdref2] if model == 2 & variable == 1
replace se = _se[csdref2] if model == 2 & variable == 1
replace pe = _b[usdref2] if model == 2 & variable == 2
replace se = _se[usdref2] if model == 2 & variable == 2

gen low = pe - 1.96 * se
gen high = pe + 1.96 * se

gen y = .
replace y = variable - 0.1 if model == 1
replace y = variable + 0.1 if model == 2
replace y = variable - 0.1 if model == 3
replace y = variable + 0.1 if model == 4

* Graph
twoway ///
	(scatter y pe if model == 1, mcolor(black) msymbol(S)) ///
	(rspike low high y if model == 1, lcolor(black) horizontal) ///
	, ///
	ytitle("") yscale(reverse) yscale(noextend nofextend noline range(0.8 2.2)) ylabel(0.9 `" "Mutually agreed" "SD referendum" "' 1.9 `" "Unilateral" "SD referendum" "', valuelabel nogrid notick) ///
	xtitle("p(onset)") xscale(noextend nofextend) xline(0, lcolor(black) lpattern(dash)) xlabel(-0.2(0.1)0.2) ///
	title("Onset", margin(bottom)) /// 
	legend(off) ///
	scheme(lean2) xsize(2) ysize(2) fxsize(100) saving(onset.gph, replace)
twoway ///
	(scatter y pe if model == 2, mcolor(black) msymbol(S)) ///
	(rspike low high y if model == 2, lcolor(black) horizontal) ///
	, ///
	ytitle("") yscale(reverse) yscale(noextend nofextend noline range(0.8 2.2)) ylabel(1 `" "Mutually agreed" "referendum" "' 2 `" "Unilateral" "referendum" "', valuelabel nogrid notick) yscale(off) ///
	xtitle("p(termination)") xscale(noextend nofextend) xline(0, lcolor(black) lpattern(dash)) xlabel(-1(0.5)1) ///
	title("Termination", margin(bottom)) /// 
	legend(off) ///
	scheme(lean2) xsize(2) ysize(2) fxsize(63) saving(cont.gph, replace)
graph combine onset.gph cont.gph ///
	, ///
	note("{it:Note:} The spikes indicate 95% confidence intervals. SD = self-determination.", span margin(small) size(small)) ///
	ycommon scheme(lean2) xsize(3) ysize(2) iscale(1) scale(1.1)	

* Tidy up
drop model - y




***********
** Table S2
***********

sum violsd_onset violsd_term csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar py wy





***********
** Table S3
***********


* Model 1
reg violsd_onset csdref2 usdref2, cl(countries_gwid)
estimates store m1
* Model 2
xtreg violsd_onset csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar lmediation1 lnvcampaign1 status_self lmilper_totpop numb_rel_grps c.py##c.py##c.py, cl(countries_gwid) fe i(gwgroupid) 
estimates store m2
* Model 3
reg violsd_term csdref2 usdref2, cl(countries_gwid)
estimates store m3
* Model 4
xtreg violsd_term csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar lmediation1 lnvcampaign1 status_self lmilper_totpop numb_rel_grps c.wy##c.wy##c.wy, cl(countries_gwid) fe i(gwgroupid) 
estimates store m4






***********
** Table S4
***********


* Model 1
xtreg violsd_onset csdref usdref status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.py##c.py##c.py, cl(countries_gwid) fe i(gwgroupid) 
estimates store m1
* Model 2
xtreg violsd_onset lcsdref1 lusdref1 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.py##c.py##c.py, cl(countries_gwid) fe i(gwgroupid) 
estimates store m2
* Model 3
xtreg violsd_onset csdref3 usdref3 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.py##c.py##c.py, cl(countries_gwid) fe i(gwgroupid) 
estimates store m3
* Model 4
xtreg violsd_onset csdref_decay_3yhalf usdref_decay_3yhalf status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.py##c.py##c.py, cl(countries_gwid) fe i(gwgroupid) 
estimates store m4
* Model 5
xtreg violsd_term csdref usdref status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.wy##c.wy##c.wy, cl(countries_gwid) fe i(gwgroupid) 
estimates store m5
* Model 6
xtreg violsd_term lcsdref1 lusdref1 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.wy##c.wy##c.wy, cl(countries_gwid) fe i(gwgroupid) 
estimates store m6
* Model 7
xtreg violsd_term csdref3 usdref3 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.wy##c.wy##c.wy, cl(countries_gwid) fe i(gwgroupid) 
estimates store m7
* Model 8
xtreg violsd_term csdref_decay_3yhalf usdref_decay_3yhalf status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.wy##c.wy##c.wy, cl(countries_gwid) fe i(gwgroupid) 
estimates store m8





************
** Figure S1
************

gen time = _n - 1 in 1/26	
gen decayvalue = 0.5^(time/3)
gen zero = 0

* Consensual referendum decay --> onset
estimates restore m4
gen pe = decayvalue * _b[csdref_decay_3yhalf]
gen se = decayvalue * _se[csdref_decay_3yhalf]
gen low = pe - 1.96 * se
gen high = pe + 1.96 * se
twoway (rarea low high time, fcolor(gs12) lcolor(gs12)) ///
	(line pe time, lcolor(black) lwidth(thick) lpattern(solid)) ///
	(line zero time, lcolor(black) lpattern(dash)) ///
	, ///
	title("Mutually agreed SD referendum --> Onset", margin(bottom) size(large)) ///
	ytitle("Effect on p(onset)", margin(zero)) yscale(noextend nofextend) ylabel(, nogrid) ///
	xtitle("# of years since referendum", margin(medsmall)) xscale(nofextend) xmtick(0(1)25) ///
	legend(off) scheme(lean2) ysize(4) xsize(6)
drop pe - high


* Unilateral referendum decay --> onset
estimates restore m4
gen pe = decayvalue * _b[usdref_decay_3yhalf]
gen se = decayvalue * _se[usdref_decay_3yhalf]
gen low = pe - 1.96 * se
gen high = pe + 1.96 * se
twoway (rarea low high time, fcolor(gs12) lcolor(gs12)) ///
	(line pe time, lcolor(black) lwidth(thick) lpattern(solid)) ///
	(line zero time, lcolor(black) lpattern(dash)) ///
	, ///
	title("Unilateral SD referendum --> Onset", margin(bottom) size(large)) ///
	ytitle("Effect on p(onset)") yscale(noextend nofextend) ylabel(, nogrid) ///
	xtitle("# of years since referendum", margin(medsmall)) xscale(nofextend) xmtick(0(1)25) ///
	legend(off) scheme(lean2) ysize(4) xsize(6)
drop pe - high

* Consensual referendum decay --> termination
estimates restore m8
gen pe = decayvalue * _b[csdref_decay_3yhalf]
gen se = decayvalue * _se[csdref_decay_3yhalf]
gen low = pe - 1.96 * se
gen high = pe + 1.96 * se
twoway (rarea low high time, fcolor(gs12) lcolor(gs12)) ///
	(line pe time, lcolor(black) lwidth(thick) lpattern(solid)) ///
	(line zero time, lcolor(black) lpattern(dash)) ///
	, ///
	title("Mutually agreed SD referendum --> Termination", margin(bottom) size(large)) ///
	ytitle("Effect on p(termination)") yscale(noextend nofextend) ylabel(, nogrid) ///
	xtitle("# of years since referendum", margin(medsmall)) xscale(nofextend) xmtick(0(1)25) ///
	legend(off) scheme(lean2) ysize(4) xsize(6)
drop pe - high





***********
** Table S5
***********

* Model 1
reg hviolsd_onset csdref2 usdref2, cl(countries_gwid)
estimates store m1
* Model 2
xtreg hviolsd_onset csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.py_hviolsd##c.py_hviolsd##c.py_hviolsd, cl(countries_gwid) fe i(gwgroupid) 
estimates store m2
* Model 3
xtreg hviolsd_onset csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lmediation1 lnvcampaign1 status_self  lv2x_polyarchy lnlrgdpcap lpko1 lmilper_totpop numb_rel_grps coldwar c.py_hviolsd##c.py_hviolsd##c.py_hviolsd, cl(countries_gwid) fe i(gwgroupid) 
estimates store m3
* Model 4
reg hviolsd_term csdref2 usdref2, cl(countries_gwid)
estimates store m4
* Model 5
xtreg hviolsd_term csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lv2x_polyarchy lnlrgdpcap lpko1 coldwar c.wy_hviolsd##c.wy_hviolsd##c.wy_hviolsd, cl(countries_gwid) fe i(gwgroupid) 
estimates store m5
* Model 6
xtreg hviolsd_term csdref2 usdref2 status_excl regaut downgr2_aut lsepkin_adjregbase1 lgiantoilfield lmediation1 lnvcampaign1 status_self lv2x_polyarchy lnlrgdpcap lpko1 lmilper_totpop numb_rel_grps coldwar c.wy_hviolsd##c.wy_hviolsd##c.wy_hviolsd, cl(countries_gwid) fe i(gwgroupid) 
estimates store m6
